<?php

namespace mbilling\BillingBundle\Model;

use Doctrine\ORM\EntityManager;
use mbilling\BillingBundle\Entity\bonuses;


Class BonusesModel
{
    protected $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    public function findAll()
    {
        $bonuses = $this->em->getRepository('BillingBundle:bonuses')->findAll();
        return $bonuses;
    }
    
    public function findByPK($bonus_id)
    {
        $bonus = $this->em->find('BillingBundle:bonuses', $bonus_id);
        return $bonus;
    }

    public function findByActive($active)
    {
        $bonuses = $this->em->getRepository('BillingBundle:bonuses')->findBy(array('is_active' => $active));
        return $bonuses;
    }
    
    public function create($oEntity)
    {
        $this->em->persist($oEntity);
        $this->em->flush();
    }

    public function removeByPK($bonus_id)
    {
        $bonus = $this->em->find('BillingBundle:bonuses', $bonus_id);
        $this->em->remove($bonus);
        $this->em->flush();
    } 
}
?>
